using UnityEngine;
using System.Collections;

public class ShakeTracker : MonoBehaviour {

	static public ShakeTracker Instance;

	Vector3 initPos;
	Vector3 offset;

	float angle;
	float angleChangeTimer = 0;

	float bumpDist = 1f;

	// Use this for initialization
	void Start () {
		Instance = this;
		initPos = transform.position;
	}
	
	// Update is called once per frame
	void Update () {
		if(Input.GetKeyDown("]"))
			Bump();

		angleChangeTimer -= Time.deltaTime;
		if(angleChangeTimer <= 0) {
			angle = Random.Range(0, 360);
		}
	
		offset = Vector3.Lerp(offset, Vector3.zero, 0.1f);

		transform.position = initPos + offset;
	}

	public void Bump() {
		offset += Quaternion.Euler(0, 0, angle) * new Vector3( bumpDist, 0, 0);
	}
}
